$("p").mouseover(function(){
  $(".san").slideDown(1500).css("display","block")
})

$(".img-1").mouseout(function(){
  $(".san").css("display","none")
})

// 客服
$("#btn").click(function(){
  layer.open({
    type: 2,
    title: '在线客服',
    shadeClose: true,
    shade: false,
    maxmin: true, //开启最大化最小化按钮
    area: ['893px', '600px'],
    content: 'http://i.xiaoi.com/'
  });
})
// 判断用户名
var s="🎎登录　|"
var a1=document.querySelector("#a-1")
var  a=localStorage.getItem("账号")
console.log(a1.innerHTML)
console.log(a)
// 为空
if(a==null){
  a1.innerhtml=s

  
  $(".li-1").css("display","none")
  var ul=document.querySelector("#ul-1")
  var xhr=`http://jx.xuzhixiang.top/ap/api/allproductlist.php?pagesize=200&pagenum=10";`
 $.ajax(xhr).then((res)=>{
   console.log(res.data)
   var html=""
   res.data.forEach((obj)=>{
     html+=`<li class="li-1" style="width="200px;">  
     <img src="../img/img-1.webp" alt=""><br>
     <p class="p-1">大哥大手机</p> <br>
     <p class="p-2">$最新补贴30元包邮</p>  </>
     </li>
     `
   })
   ul.innerHTML=html

   // 划过
   $(".li-1").hover(function(){
  console.log(this)
  $(this).css({
   "margin-top" : "23px",
   "cursor": "pointer",
   "box-shadow": "2px 2px 5px #000"
  })
   },function(){
    $(this).css({ "margin-top" : "30px",
    "box-shadow": "0px 0px 0px #000"
  })
   })
/* 点击 */
   $(".li-1").click(function(){
    console.log("1")
    layer.confirm('你还没有登录呢', {
      btn: ['登录','继续'] //按钮
    }, function(){
    location.href="登录1.html" 
    },  
      );
    });
  })
}
// 不为空
else{a1.innerHTML=a
  $.get(
    "http://jx.xuzhixiang.top/ap/api/productlist.php",
    { uid: 64610 },
    (res) => {
      var res1=res.data
      console.log(res1);
      html=""
      res1.forEach((obj)=>{
        html+=`
        <li  class="li-1" style="width="200px;"> 
        <a href="详情.html?pid=${obj.pid}">
        <img src="${obj.pimg}" alt=""><br>
        <p " class="p-1">${obj.pname}</p> <br>       
        <p class="p-3">${obj.pdesc}</p> 
        <p class="p-2">${obj.pprice}</p> <br> </a>
        </li> 
        `
      })
     
   var ul=document.querySelector("#ul-1")
  ul.innerHTML=html;

   // 划过
   $(".li-1").hover(function(){
    console.log(this)
    $(this).css({
     "margin-top" : "23px",
     "cursor": "pointer",
     "box-shadow": "2px 2px 5px #000"
    })
     },function(){
      $(this).css({ "margin-top" : "30px",
      "box-shadow": "0px 0px 0px #000"
    })
     })
    }
  );
}

// 退出
  
function tuichu(){
  var s="🎎登录　|"
  var a=localStorage.removeItem("账号")
  var a1=localStorage.getItem("账号")
  var a2=document.querySelector("#a-1")
  console.log(a)
  if(a1==null){
    layer.confirm('亲确定要退出吗？', {
      btn: ['确定','取消'] //按钮
    }, function(){
       location.href="登录1.html"
    }, function(){
    });
 
  }else{
    a2.innerHTML=s
  }
}

// 购物点击
$("#gouwu").click(function(){
  var a1=localStorage.getItem("账号")
  if(a1==null){
    layer.confirm('亲，您还没登录', {
      btn: ['登录','继续看看'] //按钮
    }, function(){
       location.href="登录1.html"
    }, function(){
    });
  }else{
   location.href="购物车.html"
  }
})